package com.sec.android.app.myfiles.feature;

import android.content.Context;

import com.sec.android.app.myfiles.feature.dlp.DlpImp;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;

import java.io.File;
import java.util.zip.ZipEntry;

/**
 * Created by jaebae on 2016-04-22.
 */
public class DlpMgr {
    private static DlpMgr sInstance;
    private DlpImp mDlpMgrImp;

    public static DlpMgr getInstance(Context context) {
        if (sInstance == null) {
            sInstance = new DlpMgr(context);
        }
        return sInstance;
    }

    private DlpMgr(Context context) {
        Object dLPManager = DlpImp.createDlpManager(context);
        if (dLPManager != null) {
            mDlpMgrImp = new DlpImp(context, dLPManager);
        }
    }

    public boolean dlpEnabled() {
        boolean bRet = false;

        if (mDlpMgrImp != null) {
            bRet = true;
        }

        return bRet;
    }

    public void setZipFileExpiry(File targetFile) {
        if (mDlpMgrImp != null) {
            mDlpMgrImp.setZipFileExpiry(targetFile);
        }
    }

    public void copyFileExpiry(FileRecord srcFile, FileRecord targetFile) {
        if (mDlpMgrImp != null) {
            mDlpMgrImp.copyFileExpiry(srcFile, targetFile);
        }
    }

    public void restoreZipFileExpiry(FileRecord src) {
        if (mDlpMgrImp != null) {
            mDlpMgrImp.restoreZipFileExpiry(src);
        }
    }

    public void putDLPFilesMap(File dstFile, String fileName) {
        if (mDlpMgrImp != null) {
            mDlpMgrImp.putDLPFilesMap(dstFile, fileName);
        }
    }

    public String getExpiryTimeInfo(FileRecord record) {
        String ret = null;
        if (mDlpMgrImp != null) {
            ret = mDlpMgrImp.getExpiryTimeInfo(record);
        }

        return ret;
    }

    public void setExtraToZipEntry(ZipEntry zipEntry, String path) {
        if (mDlpMgrImp != null) {
            mDlpMgrImp.setExtraToZipEntry(zipEntry, path);
        }
    }

    public boolean isDlpFile(FileRecord record) {
        boolean bRet = false;
        if (mDlpMgrImp != null) {
            bRet = mDlpMgrImp.isDlpFile(record);
        }

        return bRet;
    }

}
